function getCurrentDateTime() {
    const date = new Date();
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份从0开始，需+1
    const day = String(date.getDate()).padStart(2, "0");
    const hours = String(date.getHours()).padStart(2, "0");
    const minutes = String(date.getMinutes()).padStart(2, "0");
    const seconds = String(date.getSeconds()).padStart(2, "0");

    return `[${year}-${month}-${day} ${hours}:${minutes}:${seconds}]`;
}

// 保存原始的console.log方法，避免被覆盖后无法恢复
const originalLog = console.log;

// 重写console.log，自动添加时间前缀
console.log = function (...args) {
    // 生成时间前缀
    const timePrefix = getCurrentDateTime();
    // 调用原始log方法，将时间前缀和用户传入的所有参数一起输出
    originalLog.call(console, timePrefix, ...args);
};
